package com.guigu.buy.service.impl;

import com.guigu.buy.pojo.Cart;
import com.guigu.buy.mapper.CartMapper;
import com.guigu.buy.service.ICartService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author com.guigu
 * @since 2024-05-15
 */
@Service
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements ICartService {

    @Autowired
   private CartMapper cartMapper;
    @Override
    public int addCart(Cart cart) {
        return cartMapper.insertCart(cart);
    }

    @Override
    public List<Cart> showCart(Integer customerId) {
        return cartMapper.showCart(customerId);
    }

    /**
     * 根据用户ID加载购物车
     * @param customerId
     * @return
     */
    @Override
    public List<Cart> loadCartByConsumerId(Integer customerId) {
        return cartMapper.selectByConsumerId(customerId);
    }
}
